public class test6 {
    private static final long count=10_0000_0000;

    public static void main(String[] args) throws InterruptedException {
concurrence();
        serial();

    }
    public static void concurrence() throws InterruptedException {
        Thread t1=new Thread(()->{
           int a=0;
            for (int i = 0; i <count ; i++) {
                a--;
            }
        });
        long begin=System.nanoTime();
        t1.start();
        int b=0;
        for (int i = 0; i <count ; i++) {
           b--;
        }
        t1.join();
long end=System.nanoTime();
        double time=(end-begin)*1.0/1000/1000;
        System.out.println("花费时间："+time+"毫秒\n");
    }

    public  static void serial(){
        long begin=System.nanoTime();
        int a=0;
        for (int i = 0; i <count ; i++) {
            a--;
        }
        int b=0;
        for (int i = 0; i <count ; i++) {
            b--;
        }
        long end=System.nanoTime();
        double time=(end-begin)*1.0/1000/1000;
        System.out.println("花费时间："+time+"毫秒\n");
    }
}
